package 力扣日常刷题.木23一月.第07天307;

/**
 * @author 帅小伙
 * @date 2022/3/7
 * @description
 */
public class Demo02数组中重复的数字 {

    public int findRepeatNumber(int[] nums) {
        int i = 0;
        while (i < nums.length) {
            if (nums[i] == i) {
                i++;
                continue;
            }
            if (nums[nums[i]] == nums[i]) return i;
            int t = nums[i];
            nums[i] = t;
            nums[t] = t;
        }
        return -1;
    }

}
